Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
xdg-basedir
Advanced tools
The xdg-basedir package is a Node.js module that provides access to the XDG Base Directory Specification paths. It allows developers to easily find standard directories like configuration, data, and cache directories according to the XDG standards, which are commonly used in various Linux distributions.
Access to XDG Config Directory
This feature allows developers to retrieve the path to the user's XDG config directory, which is used to store configuration files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.config);
Access to XDG Data Directory
This feature provides the path to the XDG data directory, where applications can store data files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.data);
Access to XDG Cache Directory
This feature retrieves the path to the XDG cache directory, which is intended for non-essential data files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.cache);
Similar to xdg-basedir, env-paths computes paths for storing things like data, config, cache, etc. It works across different platforms (Windows, macOS, Linux), providing a broader scope compared to xdg-basedir which primarily targets XDG standards on Unix-like systems.
appdirs is another package that provides similar functionality to xdg-basedir, offering a simple interface to find appropriate platform-specific dirs (like those for data or config). It is also cross-platform and provides more comprehensive support for different operating systems compared to xdg-basedir.
Get XDG Base Directory paths
$ npm install xdg-basedir
const xdgBasedir = require('xdg-basedir');
xdgBasedir.data;
//=> '/home/sindresorhus/.local/share'
xdgBasedir.config;
//=> '/home/sindresorhus/.config'
xdgBasedir.dataDirs
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']
The properties .data
, .config
, .cache
, .runtime
will return null
in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to fall back to a temp directory.
Directory for user-specific data files.
Directory for user-specific configuration files.
Directory for user-specific non-essential data files.
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
Preference-ordered array of base directories to search for data files in addition to .data
.
Preference-ordered array of base directories to search for configuration files in addition to .config
.
MIT © Sindre Sorhus
FAQs
Get XDG Base Directory paths
The npm package xdg-basedir receives a total of 4,611,804 weekly downloads. As such, xdg-basedir popularity was classified as popular.
We found that xdg-basedir demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.